import router from './router'


import { getAccessToken } from '@/utils/auth.js'


router.beforeEach((to, from, next) => {
    
  if (getAccessToken()) {
    if (to.path === '/login') {
      next({ path: '/home' })
    }
    else next()
    }
   else {
  
    // 没有token
    if (to.path === '/login'||to.path==='/error/*') {
    
      // 直接进入
      
      next()
    } else {
      next({
        path:'/login'
      }) // 否则全部重定向到登录页
    }
  }
})

router.afterEach(() => {
  
})
